<!--
 * @LastEditors: 杜康
 * @LastEditTime: 2021-09-15 13:14:10
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Render函数</title>
</head>

<body>
  <div id="app">
    <anchor :level="1" title="特性">特性</anchor>
  </div>
  <script src="https://unpkg.com/vue/dist/vue.min.js"></script>
  <!-- <script src="index.js"></script> -->
  <script>
    Vue.component('anchor', {
      props: {
        level: {
          type: Number,
          required: true
        },
        title: {
          type: String,
          default: ''
        }
      },
      render: function (createElement) {
        console.log(this)
        return createElement(
          'h' + this.level,
          [
            createElement('a', {
              domProps: {
                href: '#' + this.title
              }
            }, this.$slots.default)
          ]
        )
      }
    })

    var app = new Vue({
      el: '#app'
    })
  </script>
</body>

</html>